﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ETL.Entity;

namespace ETL.Business.Models
{
    public class ProjectActualResourceUsageModel
    {
        public ETL_ACTUAL_RESOURCE_USAGES ActualResourceUsage { get; set; }

        public ProjectActualResourceUsageModel(ETL_ACTUAL_RESOURCE_USAGES actualResourceUsage)
        {
            this.ActualResourceUsage = actualResourceUsage;
        }

        /// <summary>
        /// Get actual resource usage id
        /// </summary>
        public decimal GenActualResourceUsageId { get { return this.ActualResourceUsage.GEN_ACTUAL_RESOURCE_USAGE_ID; } }

        /// <summary>
        /// Get the start date
        /// </summary>
        public DateTime? StartDate { 
            get {
                if (this.ActualResourceUsage.START_DATE.HasValue){
                    return this.ActualResourceUsage.START_DATE.Value;
                }
                else
                {
                    return null;
                }
            } 
        }

        /// <summary>
        /// Get the end date
        /// </summary>
        public DateTime? EndDate
        {
            get
            {
                if (this.ActualResourceUsage.END_DATE.HasValue)
                {
                    return this.ActualResourceUsage.END_DATE.Value;
                }
                else
                {
                    return null;
                }
            }
        }

        public string DisplayStartDate
        {
            get
            {
                if(StartDate.HasValue)
                {
                    return StartDate.Value.ToString("MM/dd/yyyy");
                }
                else
                {
                    return string.Empty;
                }
            }
        }
        public string DisplayStartTime
        {
            get
            {
                if (StartDate.HasValue)
                {
                    return StartDate.Value.ToString("hh:mm tt");
                }
                else
                {
                    return string.Empty;
                }
            }
        }

        public string DisplayEndDate
        {
            get
            {
                if (EndDate.HasValue)
                {
                    return EndDate.Value.ToString("MM/dd/yyyy");
                }
                else
                {
                    return string.Empty;
                }
            }
        }
        public string DisplayEndTime
        {
            get
            {
                if (EndDate.HasValue)
                {
                    return EndDate.Value.ToString("hh:mm tt");
                }
                else
                {
                    return string.Empty;
                }
            }
        }
        /// <summary>
        /// Get the end date
        /// </summary>
        public decimal PercentComplete
        {
            get
            {
                if (this.ActualResourceUsage.PERCENT_COMPLETE.HasValue)
                {
                    return this.ActualResourceUsage.PERCENT_COMPLETE.Value;
                }
                else
                {
                    return 0;
                }
            }
        }

        public string ClockOffBy
        {
            get { return ActualResourceUsage.CLOCKED_OFF_BY; }
        }
    }
}
